<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

        #container{
            width: 500px;
            margin: 0 auto;
            margin-bottom: 50px;
            margin-top: 50px;
        }
        
        li{
            width: 100px;
            height: 600px;
            display: inline-block;
            list-style-type: none;
            float: left;
        }

        ul{
            width: 510px;
            list-style-type: none;
            margin: 0 auto;
            padding: 0;
            overflow: hidden;
        }

        #butt{
            width: 80px;
            height: 38px;
        }

        #input{
            width: 400px;
            height: 32px;
        }

        h2{
            text-align: center;
            margin: 0;
            padding: 0;
        }

        p.tag{
            display: inline-block;
            padding: 0;
            margin: 0;
            padding-right: 10px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div id="app">
        <div id="container">
            <h2>Misaki天气</h2>
            <div id="searchBox">
                <input type="text" id="input" @keyup.enter="serachWeather" v-model="city">
                <button id="butt" @click="serachWeather">搜索</button>
            </div>
            <p class="tag" v-for="item in tagList" @click="tagClick(item)">{{ item }}</p>
        </div>
        <ul>
            <li v-for="item in weatherList">
                <h5 v-for="(value, key, index) in item">{{ key=="fengli"?"":value }}</h5>
            </li>
        </ul>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>
        var app = new Vue({
            el: "#app",
            data: {
                city: "",
                weatherList: [],
                tagList: ["北京", "广州", "深圳"],
            },
            methods: {
                serachWeather: function(){
                    var that = this;
                    axios.get("http://wthrcdn.etouch.cn/weather_mini?city="+this.city)
                    .then(function(response){
                        that.weatherList = response.data.data.forecast;
                        console.log(that.weatherList);
                    })
                    .catch(function(err){
                        console.log(err);
                    })
                },

                tagClick: function(item){
                    this.city = item;
                    this.serachWeather();
                },
            }
        })
    </script>
</body>
</html>